<?php

function fnMstLinks() {
    $results = mysql_query("SELECT	
                                id,
                                keterangan
                            FROM
                                mst_links
                            ORDER BY
                                id ASC");
    return $results;
}

function fnLinkById($id) {
    $results = mysql_query("SELECT	
                                id,
                                keterangan
                            FROM
                                mst_links
                            WHERE id = ".$id);
    return $results;
}

function fnAllLink() {
    $results = mysql_query("select c.* from (
                            select @rownum:=@rownum+1 as rownum, a.*
                            from mst_links a, (select @rownum:=0) b
                            ) c ");
    return $results;
}

function fnAllLinkByRange($startNum, $endNum) {
    $results = mysql_query("select c.* from (
                            select @rownum:=@rownum+1 as rownum, a.*
                            from mst_links a, (select @rownum:=0) b
                            ) c where 1=1
                            and c.rownum between ".$startNum." and ".$endNum);
    return $results;
}

function fnInsertLink($Keterangan) {
  $result = mysql_query("INSERT INTO mst_links 
                          	(Keterangan)
                         VALUES
                          	('$Keterangan')
                         ");
  return $result;
}

function fnUpdateLink($Id,$Keterangan) {
  $result = mysql_query("UPDATE mst_links SET 
                              	Keterangan = '$Keterangan'
                         WHERE Id = $Id");
  return $result;
}

function fnDeleteLink($Id) {
  $result = mysql_query("DELETE FROM mst_links 
                         WHERE Id = $Id");
  return $result;
}

?>
